//
//  HWTabBarController.m
//  嗨文
//
//  Created by 响当当 on 2019/1/8.
//  Copyright © 2019年 dongzheng. All rights reserved.
//

#import "HWTabBarController.h"
#import "HWBookViewController.h"
#import "HWMeViewController.h"
#import "HWHomeWebViewController.h"
#import "HWMoneyWebViewController.h"
#import "HWBookCircleViewController.h"

#import "HWLoginViewController.h"


@interface HWTabBarController ()<UITabBarControllerDelegate>
@property (nonatomic, copy)NSArray *infoArray;
@end

@implementation HWTabBarController

- (NSArray *)infoArray
{
    if (!_infoArray)
    {
        _infoArray = @[@{@"className": @"HWBookViewController",
                         @"titleName": @"嗨书架",
                         @"image": @"bookshelf"},
                       @{@"className": @"HWHomeWebViewController",
                         @"titleName": @"首页",
                         @"image": @"home"},
//                       @{@"className": @"HWMoneyWebViewController",
//                         @"titleName": @"嗨赚",
//                         @"image": @"himoney"},
//                       @{@"className": @"HWBookCircleViewController",
//                         @"titleName": @"嗨书圈",
//                         @"image": @"circle"},
                       @{@"className": @"HWMeViewController",
                         @"titleName": @"我的",
                         @"image": @"my"}];
    }
    return _infoArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSMutableArray *viewControllers = [NSMutableArray array];
    
    for (NSDictionary *dict in self.infoArray)
    {
        UIViewController *vc = [[NSClassFromString(dict[@"className"]) alloc] init];
        UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:vc];
        
        navi.tabBarItem.title = dict[@"titleName"];
        navi.tabBarItem.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@_normal",dict[@"image"]]];
        navi.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected", dict[@"image"]]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        
        [viewControllers addObject:navi];
    }
    
    self.viewControllers = viewControllers;
    self.selectedViewController = [self.viewControllers objectAtIndex:1];
    
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:LCHexColor(0xF54337)}
                                             forState:UIControlStateSelected];
}


@end
